package com.devilvan.betrice.opgg.po;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.devilvan.betrice.common.BasePo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;
import org.hibernate.annotations.DynamicInsert;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;

/**
 * @author Evad.Wu
 * @Description OPGG-英雄信息 映射
 * @date 2022-10-04
 */
@Setter
@Getter
@ToString(exclude = {"opggHeaderPo", "opggChampionPositionPoList", "opggChampionRolePoList"})
@NoArgsConstructor
@Accessors(chain = true)
@TableName(value = "OPGG_CHAMPION_META")

@Entity
@Table(name = "OPGG_CHAMPION_META")
@DynamicInsert
@EntityListeners(AuditingEntityListener.class)
@Schema(description = "OPGG-英雄信息 映射")
public class OpggChampionMetaPo extends BasePo implements Serializable {
    @Serial
    private static final long serialVersionUID = -1024974003256805811L;
    @Schema(description = "HEADER的ID")
    @TableField(value = "HID")
    @Column(name = "HID", columnDefinition = "BIGINT(19) NOT NULL COMMENT 'HEADER的ID'")
    private Long hid;
    @Schema(description = "英雄ID")
    @TableField(value = "CHAMPION_ID")
    @Column(name = "CHAMPION_ID", columnDefinition = "BIGINT(19) NOT NULL COMMENT '英雄ID'")
    private Long championId;
    @Schema(description = "英雄称号")
    @TableField(value = "NAME")
    @Column(name = "NAME", columnDefinition = "VARCHAR(32) NOT NULL COMMENT '英雄称号'")
    private String name;
    @Schema(description = "英雄名称")
    @TableField(value = "KEY_NAME")
    @Column(name = "KEY_NAME", columnDefinition = "VARCHAR(16) NOT NULL COMMENT '英雄名称'")
    private String keyName;
    @Schema(description = "英雄头像URL")
    @TableField(value = "IMG_URL")
    @Column(name = "IMG_URL", columnDefinition = "TEXT COMMENT '英雄头像URL'")
    private String imgUrl;
    @Schema(description = "平均数据-胜率")
    @TableField(value = "AVG_WIN_RATE")
    @Column(name = "AVG_WIN_RATE", columnDefinition = "DECIMAL(12) COMMENT '平均数据-胜率'")
    private BigDecimal avgWinRate;
    @Schema(description = "平均数据-出场率")
    @TableField(value = "AVG_PICK_RATE")
    @Column(name = "AVG_PICK_RATE", columnDefinition = "DECIMAL(12) COMMENT '平均数据-出场率'")
    private BigDecimal avgPickRate;
    @Schema(description = "平均数据-禁用率")
    @TableField(value = "AVG_BAN_RATE")
    @Column(name = "AVG_BAN_RATE", columnDefinition = "DECIMAL(12) COMMENT '平均数据-禁用率'")
    private BigDecimal avgBanRate;
    @Schema(description = "平均数据-KDA")
    @TableField(value = "AVG_KDA")
    @Column(name = "AVG_KDA", columnDefinition = "DECIMAL(12) COMMENT '平均数据-KDA'")
    private BigDecimal avgKda;
    @Schema(description = "平均数据-梯队")
    @TableField(value = "AVG_TIER")
    @Column(name = "AVG_TIER", columnDefinition = "INT(10) COMMENT '平均数据-梯队'")
    private Integer avgTier;
    @Schema(description = "平均数据-排名")
    @TableField(value = "AVG_RANK")
    @Column(name = "AVG_RANK", columnDefinition = "INT(10) COMMENT '平均数据-排名'")
    private Integer avgRank;

    @Schema(description = "英雄基本信息")
    @TableField(exist = false)
    @ManyToOne(targetEntity = OpggHeaderPo.class, cascade = CascadeType.ALL, fetch = FetchType.LAZY)
    @JoinColumn(name = "HID", referencedColumnName = "ID", insertable = false, updatable = false)
    private OpggHeaderPo opggHeaderPo;
    @Schema(description = "英雄位置信息")
    @TableField(exist = false)
    @OneToMany(targetEntity = OpggChampionPositionPo.class, mappedBy = "opggChampionMetaPo", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
    private List<OpggChampionPositionPo> opggChampionPositionPoList;
    @Schema(description = "英雄角色定位信息")
    @TableField(exist = false)
    @OneToMany(targetEntity = OpggChampionRolePo.class, mappedBy = "opggChampionMetaPo", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
    private List<OpggChampionRolePo> opggChampionRolePoList;
}
